

(defun rx/turn-on-column-number-mode ()
  "Unconditionally turn on `column-number-mode' for the current buffer."
  (set (make-variable-buffer-local 'column-number-mode) t))

(defun rx/turn-off-line-number-mode ()
  "Unconditionally turn off `line-number-mode' fur the current buffer.."
  (set (make-variable-buffer-local 'line-number-mode) nil))

(defun rx/define-keys (map key def &rest bindings)
  "Like `define-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
  (while key
    (define-key map (kbd key) def)
    (setq key (pop bindings)
          def (pop bindings))))

(defun rx/global-set-keys (key def &rest bindings)
  "Like `global-set-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
  (while key
    (global-set-key (kbd key) def)
    (setq key (pop bindings)
          def (pop bindings))))

(defun rx/local-set-keys (key def &rest bindings)
  "Like `local-set-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
  (while key
    (local-set-key (kbd key) def)
    (setq key (pop bindings)
          def (pop bindings))))

(defun rx/toggle-org-reader ()
  "Toggle `variable-pitch-mode' and other niceties for Org reading."
  (interactive)
  (make-variable-buffer-local 'org-hide-emphasis-markers)
  ;; Because we revert the buffer, we need to set org-hide-emphasis-markers twice.
  (if org-hide-emphasis-markers
      (progn
        (follow-mode -1)
        (setq org-hide-emphasis-markers nil)
        (setq display-line-numbers-type 'visual)
        (revert-buffer)
        (setq org-hide-emphasis-markers nil)
        (variable-pitch-mode -1))
    (split-window-right)
    (follow-mode)
    (setq org-hide-emphasis-markers t)
    (setq display-line-numbers-type t)
    (revert-buffer)
    (setq org-hide-emphasis-markers t)
    (variable-pitch-mode 1)))

 (defun rx/take-screenshot-region ()
    "Take a screenshot into a time stamped unique-named file in the
  same directory as the org-buffer and insert a link to this file."
    (interactive)
    (let ((filename
           (concat
            (make-temp-name
             (concat (buffer-file-name)
                     "_"
                     (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")))
      (call-process "scrot" nil nil nil "-s" filename)
      (insert (concat "[[" filename "]]"))
      (org-display-inline-images)))
(global-set-key (kbd "<f12>") 'rx/take-screenshot-region)

(provide 'functions)
